package game;

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.LinkedList;

public class GerenciadorInimigo 
{
	public LinkedList<BaseEnemy> enemies;
	public LinkedList<Ainteligence> iaEnemies;
	float time, fixedTime;
	boolean QtdInimigos = false;
	
	public GerenciadorInimigo(float timeSpawn, int QtdInimigos)
	{
		 enemies = new LinkedList<BaseEnemy>();
		 iaEnemies = new LinkedList<Ainteligence>();
		 time = timeSpawn;
	}
	public GerenciadorInimigo(float timeSpawn)
	{
		time = timeSpawn;
	}
	
	public void Update(BaseEnemy e, Rectangle[] mapa, AnimatedSprite personagem, float velocityEnemie)
	{
		time -= Time.getInstance().getLoopTime();
		
		if(QtdInimigos && time < 0)
		{
			enemies.add(e);
			iaEnemies.add(new Ainteligence(e, personagem, mapa, velocityEnemie));
			time = fixedTime;
		}	
		for(int i = 0; i< enemies.size(); i++)
		{
			enemies.get(i).Update();
			iaEnemies.get(i).Update();
			enemies.set(i, (BaseEnemy)iaEnemies.get(i).returnEnemie());
		}
	}
	public void Draw(Graphics2D g2d)
	{
		for(BaseEnemy i : enemies)
		{
			if(enemies.size() > 0)
			i.draw(g2d);
		}
	}
	public void AddEnemy(BaseEnemy e, AnimatedSprite personagem, Rectangle[] mapa, float velocityEnemie)
	{
		enemies.add(e);
		iaEnemies.add(new Ainteligence(e, personagem, mapa, velocityEnemie));
	}
}
